	package com.OnTimeTeam.OnTime;

	import android.app.ProgressDialog;
	import android.os.AsyncTask;

	public class TransitQueryOnBackground extends AsyncTask<String, Void, TransitRoadsQuery> { 

	    ProgressDialog progressDialog;
		private Exception exception;
	    private SetSmart host;		
		
		public TransitQueryOnBackground(SetSmart host){
			this.host = host;
			this.exception = null;
		}
		
		
	    protected TransitRoadsQuery doInBackground(String... params) {//In Background
	    	
	    	TransitRoadsQuery roadsQ = null;
			try {
				roadsQ = new TransitRoadsQuery(params[0], params[1], params[2]);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				exception = e;
			
			}
	    	
	    	return roadsQ;
	    }      

	    protected void onPreExecute() {//Before
	    	super.onPreExecute();

	    	progressDialog = ProgressDialog.show(host, host.getResources().getString(R.string.calculating), host.getResources().getString(R.string.pleaseWait));
	    }
	    
	    protected void onPostExecute(TransitRoadsQuery result) {//After
	    	
	    	progressDialog.dismiss();
	    	//also means roadsQ == null
	    	if(exception != null)
	    		host.displayTransitBadStatusResponse(exception);
	    	else
	    		host.showTransitOptions(result);
	    }



	    protected void onProgressUpdate(Void... values) {
	    	
	    	
	    }
	


}
